package com.example.fruitdemo.pojo;

import com.alibaba.fastjson.annotation.JSONField;


import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;


import javax.validation.constraints.Email;

import javax.validation.constraints.Pattern;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

@Data
@TableName(value = "tb_user")
@AllArgsConstructor
@NoArgsConstructor
public class User {

    private Long id;

    @TableField("username")
    @Pattern(regexp = "^[a-zA-Z0-9_-]{6,16}$",message = "用户名格式不正确")
    private String username;

    @TableField("password")
    @Pattern(regexp = "^[\\w_]{6,12}$",message = "密码格式不正确")
    private String password;

    @TableField("phone")
    private Long phone;

    @TableField("email")
    @Email(message = "必须是邮箱格式")
    private String email;

    @TableField("address")
    private String address;

    @TableField(value = "createtime",fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
    private LocalDateTime createtime;

   @TableField(value = "updatetime",fill = FieldFill.INSERT_UPDATE)
   @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
    private LocalDateTime updatetime;


}
